<template>
  <status :msgDetail="reason" btnTxt="" @onBtnClick="linkInfo" @onBack="info"  noTitle type="warning" title="打回原因"></status>
</template>

<script>
  import status from '../../../../components/module/Status.vue'
  import {CHECK_REASON, GET_AUTH_INFO} from '../../../../assets/js/api'

  let components = {};
  components[status.name] = status;
  export default {
    components: components,
    name: 'checkBack',
    data() {
      return {
        reason: '',
        status: null
      }
    },
    async created() {
      const {status} = this.$route.params
      if (status && status === 3) {
        this.status = status;
        console.log(this.status)
        let {member_id, token, tel} = this.$store.state.currentUser;
        let json = await this.$http.post(GET_AUTH_INFO, {member_id: member_id, token: token, tel: tel}, {
          show: true,
          type: 'mini'
        });
        console.log(json)
        if (json.result === 1) {
          for (let item of Object.keys(json.data)) {
            if (item === 'reason') {
              continue
            }
          }
          this.reason = json.data.reason
        }
      } else {
        let json = await this.$http.post(CHECK_REASON);
        if (json.result === 1) {
          this.reason = json.data;
        }
      }

    },
    methods: {
      linkInfo() {
        console.log(this.status)
        if(this.status===3){
          this.$router.push({name: 'authInfo'});
        } else{
          this.$router.replace({path: '/profile/info'});
        }
      },
      info(){
        console.log('kkk')
       this.$router.go(-1);
      }
    }
  }
</script>
